<template>
  <van-nav-bar
      title="草稿箱"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
  />
  <van-tabs v-model:active="activeTab">
    <van-tab title="经验">
      <van-list
          v-model:loading="loading"
          :finished="finished"
          @load="onLoad"
      >
        <van-swipe-cell  v-for="d in expLists" >
          <van-cell  :title="d.expTitle" :label="d.expTime" :value="d.expType" />
        </van-swipe-cell>
      </van-list>
    </van-tab>
    <van-tab title="回答">
      <van-list
          v-model:loading="loading"
          :finished="finished"
          @load="onLoad"
      >
        <van-swipe-cell  v-for="d in expLists" >
          <van-cell  :title="d.expTitle" :label="d.expTime" :value="d.expType" />
        </van-swipe-cell>
      </van-list>
    </van-tab>
  </van-tabs>
</template>

<script setup>
import {ref} from 'vue'
import {useRouter} from "vue-router";
import axios from "axios";
import {showToast} from "vant";
import {get} from "../../util/request.js";
const router=useRouter();
const onClickLeft = () => {
  router.push("/myCreate");
  // 返回按钮逻辑
};
const activeTab = ref(0);
const loading = ref(false);
const finished = ref(false);
const expLists =ref([])//经验数据
const onLoad=()=>{
  get(
    'home/getExp'
  ).then(
      (data) => {
        console.log(JSON.stringify(data))
        console.log("获取处理器的数据：" + JSON.stringify(data.data))

        // 加载状态结束
        loading.value = false;
        finished.value = true

        if (data.code == 0) {
          showToast("查询成功");
          expLists.value = data.data;// 初始化界面
        } else {
          showToast("查询失败");
        }


      })
      .catch(
          function () {
            alert("服务器错误")
          }
      )
}
</script>

<style scoped>

</style>